﻿Imports Control_Vuelos_BL

Public Class frmSegCambiarPassword
    Private _IsOperationInProgress As Boolean
    Private ReadOnly _UsuarioBL As New UsuarioBL()
    Private _coduser As String

    Public Property coduser() As String
        Get
            Return _coduser
        End Get
        Set(value As String)
            _coduser = value
        End Set
    End Property

    Public Property IsOperationInProgress() As Boolean
        Get
            Return _IsOperationInProgress
        End Get
        Set(ByVal value As Boolean)
            _IsOperationInProgress = value
            UcChangePassword1.gpswnew.Enabled = Not value
            UcChangePassword1.gpswconf.Enabled = Not value
            cmdchgpsw.Enabled = Not value
        End Set
    End Property

    Private Sub frmSegCambiarPassword_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        IsOperationInProgress = True
        AddHandler UcChangePassword1.cmdauth.Click, AddressOf prl_Authenticar
    End Sub

    Private Sub prl_Authenticar()
        If _UsuarioBL.pr_ValidarUsuario(coduser, UcChangePassword1.gpswuser.EditValue) Then
            IsOperationInProgress = False
        End If
    End Sub

    Private Sub cmdcancel_Click(sender As System.Object, e As System.EventArgs) Handles cmdcancel.Click
        Close()
    End Sub

    Private Sub cmdchgpsw_Click(sender As System.Object, e As System.EventArgs) Handles cmdchgpsw.Click
        If UcChangePassword1.DxValidationProvider1.Validate Then
            If UcChangePassword1.gpswnew.EditValue.Equals(UcChangePassword1.gpswconf.EditValue) Then
                If _UsuarioBL.pr_RestablecerContrasena(p_coduser, UcChangePassword1.gpswnew.EditValue) Then
                    Close()
                End If
            End If
        End If
    End Sub

End Class